<template>
	<view class="my-content-info">
	<!-- <view class="head">
		<view class="back" @tap="back"><u-icon name="arrow-left" color="#2979ff" size="24"></u-icon></view>
		<view class="title">柜员管理</view>
		
	</view> -->
	<view class="addBtn" @tap="addEmploy">新增柜员</view>
	<view class="list">
		<view class="li" v-for="(item,index) in list" :key="index">
			<view class="li-top">
				<view class="li-left"><u-avatar :src="item.headPhoto" size="60"></u-avatar></view>
				<view class="li-middle">
					<view class="dd"><view class="name">柜员姓名：{{item.realName}}</view><view class="state">{{item.isOnline?"登录中":"未登录"}}</view></view>
					<view class="dd">编号：{{item.id}}</view>
					<view class="dd">帐号：{{item.userName}}</view>
					<view class="dd">密码：*******</view>
				</view>
				<!-- <view class="li-right">
					<view class="option-btn"><u--image  src="/static/out.png" width="90rpx" height="28rpx" @click="outLogin"></u--image></view>
				</view> -->
			</view>
			<view class="li-bottom">
				<view class="bottom-btn" @click="modify(item)">修改</view>
				<view class="bottom-btn" @click="dele(item)">删除</view>
			</view>
			<u-modal :show="show" :title="title" :content='content' @confirm="sureDel" @close="closeModel" :closeOnClickOverlay="true"></u-modal>
		</view>
	</view>
	</view>
</template>

<script>
	import {
		getStoreData,
		dealNum,
		setStoreData,
		httpPost,
		httpGet,
	} from "@/utils/http.js";
	const pic1 = require(`@/img/my/my1.png`);
	const avatar = require(`@/img/my/avatar1.jpg`);
	export default {
		data() {
			return {
				src:"",
                pageNo:1,
				pageSize:10,
				list:[],
				show:false,
				content:"确定删除吗？",
				title:"提示",
				clerkInfo:{}
			};
		},
		onLoad() {
			this.userInfo = getStoreData("userInfo");
            this.getEmployeeList();
		},
		methods: {
			back(){
				uni.navigateBack();
			},
			getEmployeeList(){
				httpPost(`/api/barcodecashier/list`, {pageNo:this.pageNo,pageSize:this.pageSize})
					.then((res) => {
						console.log(res)
						if (res.data) {
				         this.list=res.data.list;
						}
				
					})
					.catch((e) => {});
			},
			addEmploy(){
				uni.navigateTo({
					url: '/pages/employeeManage/addEmployee'
				});
			},
			outLogin(){},
			submit() {
				if (!this.loginInfo.userName) {
					uni.$u.toast("请输入账号");
					return
				}
				if (!this.loginInfo.password) {
					uni.$u.toast("请输入密码");
					return
				}
				httpPost(`/api/sellerstorecashierlogin/loginSubStore`, this.loginInfo)
					.then((res) => {
						console.log(res)
						if (res.data) {

						}

					})
					.catch((e) => {});

			},
			modify(data){
				uni.navigateTo({
					url: '/pages/employeeManage/addEmployee?modify='+JSON.stringify(data)
				});
			},
			dele(data){
				this.clerkInfo=data;
				this.show=true;
			},
			sureDel(){
				console.log(this.clerkInfo.id)
				httpGet(`/api/barcodecashier/delete/`+this.clerkInfo.id)
					.then((res) => {
						console.log(res)
						this.getEmployeeList()
						this.show=false;
					})
					.catch((e) => {});
				
			},
			closeModel(){
				this.show=false;
			}


		},
	};
</script>

<style lang="scss">
	.my-content-info {
		background-color: #F7F7F7;
		padding-top: 20rpx;
		height:100vh;
		
		.head{
			padding-left: 20rpx;
			padding-right: 30rpx;
			padding-top: 20rpx;
			padding-bottom: 20rpx;
			background-color: #fff;
			display: flex;
			flex-direction: row;
			justify-content: space-between;
			.title{
				font-size: 36rpx;
			}
			.add{
				margin-top: 8rpx;
			}
			margin-bottom: 20rpx;
		}
		.list{
			padding-left: 30rpx;
			padding-right: 30rpx;
			.li{
				background-color: #fff;
				padding: 30rpx;
				border-radius: 10rpx;
				margin-bottom: 20rpx;
				.li-top{
					display: flex;
					flex-direction: row;
					justify-content: flex-start;
					padding-bottom: 30rpx;
					.li-left{
						margin-right: 30rpx;
					}
					.li-middle{
						width: 390rpx;
						.dd{
							display: flex;
							flex-direction: row;
							justify-content: flex-start;
							font-size: 24rpx;
							color: #AAAAAA;
							margin-bottom: 6rpx;
							.state{
								width: 80rpx;
								height: 36rpx;
								background: linear-gradient(to right,#3CBAF6,#56D1FC);
								font-size: 20rpx;
								color: #fff;
								text-align: center;
								line-height: 36rpx;
								border-radius: 20rpx;
								margin-left: 20rpx;
							}
							.name{
								font-size: 26rpx;
								color: #333333;
							}
						}
					}
				}
				.li-bottom{
					display: flex;
					flex-direction: row;
					justify-content: space-between;
					padding-top: 30rpx;
					border-top: 1rpx solid #F7F7F7;
					.bottom-btn{
						width: 50%;
						text-align: center;
						position: relative;
					}
					.bottom-btn:nth-child(1):after{
						display: block;
						content: "";
						width: 2rpx;
						background-color: #F7F7F7;
						height: 40rpx;
						position: absolute;
						right: 0;
						top:0;
					}
				}
			}
		}
	}
	.addBtn{
		text-align: center;
		width: 690rpx;
		margin-left: 30rpx;
		line-height: 70rpx;
		background-color: #3CBAF6;
		color: #fff;
		border-radius: 10rpx;
		margin-bottom: 20rpx;
	}
</style>